package com.uyaer.wheel.tick
{
	import com.uyaer.wheel.utils.HashMap;
	
	import flash.utils.Timer;
	/**
	 *自定义timer，继承于timer 
	 * @author hc
	 * 
	 */	
	internal class UTimer extends Timer
	{
		private var listenerMap:HashMap = new HashMap();
		public function UTimer(delay:Number, repeatCount:int=0)
		{
			super(delay, repeatCount);
		}
		
		override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
			super.addEventListener(type, listener, useCapture, priority, useWeakReference);
			if(listenerMap.hasKey(type)){
				throw "TimerInfo::addEventListener()重复注册事件，小心内存溢出";
			}
			listenerMap.put(type,listener);
		}
		
		override public function reset():void{
			var fun:Function;
			for each (var type:String in listenerMap.getKeys()){
				fun = listenerMap.get(type);
				this.removeEventListener(type,fun);
			}
			listenerMap.clear();
			super.reset();
		}
		
		
	}
}